This section describes the five basic lp commands.
The form of the lp command is:
Every time an lp request is made, a request ID is assigned to the job, and a record of the request is sent to you. The request ID has this form:lp [options] filename...
destination is the printer or class of printers to which the job has been routed. seqnum is an arbitrary sequence number assigned to the job by the lp system.destination-seqnum
lp has three options that are particularly useful: -n, -d, and -c.
lp -nnumber
number is the number of copies to print. Note that there is no space between -n and number.
lp -ddestination filename...
lp -c filename...
Example 2-1 : Simple lp Print Requests
To request a printout, you can use the lp command several different ways. The entries in Example 2-1 perform identical functions, sending a simple print request to the default printer.lp myfile
lp < myfile
cat myfile | lp
Example 2-2 : Complex lp Print Request
The entry in Example 2-2 prints three copies on printer foo and creates a copy of the file for the printer to process, ensuring that if changes are made to the file after the print request, the original file is printed.lp -n3 -dfoo -c myfile
Any user can cancel any other user's job. If you cancel another user's print request, mail is sent to that user. Once you cancel a job, you can request that it be printed again only with the lp command:
Using the printer-name cancels the job currently being printed. Using the request-ID cancels the specified job whether or not it is currently being printed, as shown in Example 2-3.cancel printer-name
cancel request-ID
Example 2-3 : Using the cancel Command
Issuing a cancel command does not work when the job is being printed on a remote printer. To cancel a print job on a remote printer, log in to the remote system and issue the cancel command.cancel myprinter
request "myprinter-16" cancelled
cancel myprinter-17
request "myprinter-17" cancelled
You can send job requests to a printer that has been disabled. The jobs are put in the queue but are not printed until the printer is enabled.
To disable a printer, type:
disable [-c] [-r"reason"] printer(s)
enable printer...
Example 2-4 : Using the enable Command
disable -r"paper jam" myprinter
printer "myprinter" now disabled
enable myprinter
printer "myprinter" now enabled
lpstat [options]
Use the -t option to display a complete report on the status of the lp system.
For a complete list of options, see the lpstat(1) reference page.
Example 2-5 shows an example lpstat -t command and its result:
Example 2-5 : Using the lpstat Command
lpstat -t
scheduler is running
system default destination: myprinter
members of class foo:
myprinter
device for myprinter: /dev/plp
myprinter accepting requests since Jul 31 21:40
foo accepting requests since Jul 30 12:23
printer myprinter now printing foo-18
enabled since Aug 5 15:34
foo-18 mylogin 3156 Aug 7 17:11 on myprinter